package org.cfk.asyncdownloadtutorial.downloadhandler;

import lombok.Data;
import org.cfk.asyncdownloadtutorial.annotation.AsyncDownloadJobWorker;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

@Component
public class ExampleDownloadHandler {

    /**
     * 示例下载处理方法
     * 
     * @param params 下载参数
     * @param file 输出文件
     */
    @AsyncDownloadJobWorker("example")
    public void handleExampleDownload(DownloadParams params, File file) throws IOException {
        try (FileWriter writer = new FileWriter(file)) {
            // 这里实现具体的下载逻辑
            writer.write("示例内容：" + params.getContent());
        }
    }

    @Data
    public static class DownloadParams {
        private String content;
    }
}